//
//  HomeLivingTableView.m
//  LiveStar
//
//  Created by 漪珊 on 2016/12/20.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "HomeLivingTableView.h"
#import "StarPredictCell.h"
@interface HomeLivingTableView()<UITableViewDelegate,UITableViewDataSource,StarPredictCellDelegate>

@end
@implementation HomeLivingTableView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        self.separatorStyle = UITableViewCellSeparatorStyleNone;
        self.delegate = self;
        self.dataSource = self;
    }
    return self;
}

#pragma mark -- tableView 代理方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    StarPredictCell *cell = [StarPredictCell loadNibCellWithTabelView:tableView];
    cell.backgroundColor = [UIColor whiteColor];
    cell.predictListModel = self.dataArr[indexPath.row];
    cell.delegate = self;
    if (indexPath.row == 1||indexPath.row == 3||indexPath.row == 5||indexPath.row == 7) {
        cell.predictGitTip.hidden = NO;
        cell.predictRedPaperTip.hidden = NO;
    }
    if (indexPath.row == 0) {
        cell.predictStarName.text = @"韩雪";
        cell.predictImg.image = [UIImage imageNamed:@"predict_1"];
    } else if (indexPath.row == 1) {
        cell.predictStarName.text = @"胡歌";
        cell.predictImg.image = [UIImage imageNamed:@"predict_2"];
    } else if (indexPath.row == 2) {
        cell.predictStarName.text = @"江疏影";
        cell.predictImg.image = [UIImage imageNamed:@"predict_3"];
    } else if (indexPath.row == 3) {
        cell.predictStarName.text = @"蒋欣";
        cell.predictImg.image = [UIImage imageNamed:@"predict_4"];
    } else if (indexPath.row == 4) {
        cell.predictStarName.text = @"李易峰";
        cell.predictImg.image = [UIImage imageNamed:@"predict_5"];
    } else if (indexPath.row == 5) {
        cell.predictStarName.text = @"刘涛";
        cell.predictImg.image = [UIImage imageNamed:@"predict_6"];
    } else if (indexPath.row == 6) {
        cell.predictStarName.text = @"吴亦凡";
        cell.predictImg.image = [UIImage imageNamed:@"predict_7"];
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

#pragma mark -- 区头视图
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 115;
}

#pragma mark -- 直播预选
- (void)PredictLivingWithCell:(StarPredictCell *)starPredictCell {
    kButtonRadius(starPredictCell.predictBtn, 0);
    starPredictCell.predictBtn.backgroundColor = [UIColor mainColor];
    [starPredictCell.predictBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [starPredictCell.predictBtn setTitle:@"已订阅" forState:UIControlStateNormal];
}

@end
